<% layout('/layouts/_default.html', {title: '参数设置', libs: ['validate']}){ %>
<div class="main-content">
  <div class="box box-main">
    <div class="box-header">
      <div class="box-title">
        <i class="fa icon-wrench"></i> ${op=='add' ? '新增参数' : '编辑参数'}
      </div>
      <div class="box-tools pull-right">
        <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
      </div>
    </div>
    <#form:form id="inputForm" model="${row}" action="${ctxPath}/config/save" method="post" class="form-horizontal">
      <#form:hidden path="id" />
      <div class="box-body">
        <div class="form-unit">基本信息</div>
        <div class="row">
          <div class="col-xs-6">
            <div class="form-group">
              <label class="control-label col-sm-4">
                <span class="required">*</span> 参数名称：</label>
              <div class="col-sm-8">
                <#form:input path="configName" maxlength="100" class="form-control" 
                  readonly="${row.isSys=='1'}"/>
              </div>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-6">
            <div class="form-group">
              <label class="control-label col-sm-4">
                <span class="required">*</span> 参数键名：</label>
              <div class="col-sm-8">
                <#form:input path="configKey" maxlength="100" class="form-control required"
                  readonly="${row.isSys=='1'}"
                  remote="${ctxPath}/config/checkConfigKey?oldConfigKey=${row.configKey}"
                  data-msg-remote="参数键名已存在"/>
              </div>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-12">
            <div class="form-group">
              <label class="control-label col-sm-2">
                参数键值：</label>
              <div class="col-sm-8">
                <#form:textarea path="configValue" rows="4" maxlength="2000" class="form-control "/>
              </div>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-6">
            <div class="form-group">
              <label class="control-label col-sm-4" title="">
                <span class="required ">*</span> 是否系统：<i class="fa icon-question hide"></i></label>
              <div class="col-sm-8">
                <#form:radio path="isSys" dictType="sys_yes_no" class="form-control required " />
              </div>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-xs-12">
            <div class="form-group">
              <label class="control-label col-sm-2">参数描述：</label>
              <div class="col-sm-8">
                <#form:textarea path="remarks" rows="3" maxlength="200" class="form-control"/>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="box-footer">
        <div class="row">
          <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> 保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> 关 闭</button>
          </div>
        </div>
      </div>
    </#form:form>
  </div>
</div>
<% } %>
<script>
$("#inputForm").validate({
  submitHandler: function(form){
    js.ajaxSubmitForm($(form), function(data){
      js.showMessage(data.message);
      if(data.result == Global.TRUE){
        js.closeCurrentTabPage(function(contentWindow){
          contentWindow.page();
        });
      }
    }, "json");
  }
});
</script>